﻿@using System.Web.Script.Serialization
@{
    ViewBag.Title = T("Customer.Info.Title");
}


<label>@T("Customer.Info.NickName.Title")</label>
<input type="text" data-bind="value:NickName"/>

<label>@T("Customer.Info.Intro.Title")</label>
<textarea data-bind="value:Intro" rows="10"  class="input-xxlarge">

</textarea>


<div>
    <input type="button"  data-bind="value:'@T("Customer.Info.Save")', click:SaveCustomerInfo" class="btn btn-primary"/>
</div>




@{
    var model = ViewBag.Model;
    var jsonData = new HtmlString(new JavaScriptSerializer().Serialize(model));
}
@section scripts
{
    
    
    <script>
        
        var init = @jsonData;

        function CustomerInfoEditModel() {
            var self = this;

            self.Id = ko.observable(init.Id);
            self.NickName = ko.observable(init.NickName);
            self.Intro= ko.observable(init.Intro);

            self.SaveCustomerInfo = function() {
                
                $.ajax({
                    url: "/api/CustomerApi/SaveCustomerInfo",
                    type: 'post',
                    data: ko.toJSON(self),
                    contentType: 'application/json',
                    success: function (result) {

                        if (result.Status == "0") {
                            
                            toastr.success(result.Message);
                        } else {
                            toastr.error(result.Message);
                        }
                    }
                });
            };
        }

        var vm = new CustomerInfoEditModel();
        ko.applyBindings(vm);
    </script>
    
    

}
